package com.mystore.framework.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mystore.framework.service.BaseService;
import icu.mhb.mybatisplus.plugln.base.mapper.JoinBaseMapper;
import icu.mhb.mybatisplus.plugln.base.service.impl.JoinServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public abstract class IBaseServiceImpl<M extends JoinBaseMapper<T>,T> extends JoinServiceImpl<M,T> implements BaseService<T> {

    @Override
    public T selectById(int id) {
        return baseMapper.selectById(id);
    }
    @Override
    @Transactional
    public int insertOne(T t) {
        return baseMapper.insert(t);
    }

    @Override
    @Transactional
    public boolean updateOne(T t) {
        return baseMapper.updateById(t)>0;
    }

    @Override
    @Transactional
    public boolean deleteById(int id) {
        return baseMapper.deleteById(id)>0;
    }

    @Override
    public List<T> selectAll() {
        return baseMapper.selectList(null);
    }

    @Override
    public IPage<T> selectPage(Page<T> page) {
        return baseMapper.selectPage(page,null);
    }

}
